package com.joinway.framework.support.logging;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.joinway.framework.data.jdbc.repository.TableRepository;

@Deprecated
@Service
public class LoggingService {

	@Autowired(required=false) TableRepository repository;
	
//	@Autowired(required=false) MongoTemplate temp;
	
	private final static Logger log = LoggerFactory.getLogger(LoggingService.class);
			
	public void log(Object domain){
		try{
			if(repository != null){
				repository.save(domain);
			}
		}catch(Throwable t){
			log.warn("failed to insert db log", t);
			log.info(domain.toString());
		}
	}
	
//	public void log(NoSqlEntity entity){
//		try{
//			if(temp != null){
//				temp.save(entity, entity.getCollectionName());
//			}
//		}catch(Throwable t){
//			log.warn("failed to insert nosql log", t);
//			log.info(entity.toString());
//		}
//	}
}

